package com.myna.csv.initial;

import com.myna.csv.domain.PropertyStr;
import com.myna.csv.utils.PropertyUtil;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static com.myna.csv.utils.DomainRdcMappingMetadataUtil.getJsonMapping;

public class InitialProcessor {
    public static String XmlPath;
    public static String rdcFilePath;
    public static String rdcFilePIPath;
    public static String jsonMapping;

    //File Number
    public static int fileNumber;

    //File upload path
    public static String fileUploadPath;

    public static List<String> needed_pi_properIds_List = new ArrayList<>();
    public static List<String> StubProper_properIds_List = new ArrayList<>();
    public static List<String> category_list = new ArrayList<>();

    //propertyId and propertyName mapping
    public static Map<Long, String> jsonMappingMap = null;

    public void init() {
        XmlPath = PropertyUtil.getValue(PropertyStr.XMLPATH);
        rdcFilePath = PropertyUtil.getValue(PropertyStr.RDCFILEPATH);
        rdcFilePIPath = PropertyUtil.getValue(PropertyStr.RDCFILEPIPATH);
        jsonMapping = PropertyUtil.getValue(PropertyStr.JSONMAPPING);

        fileNumber = Integer.parseInt(PropertyUtil.getValue(PropertyStr.FILE_NUMBER)) + 1;

        fileUploadPath = PropertyUtil.getValue(PropertyStr.FILEUPLOADPATH);

        String[] stubProperArr = PropertyUtil.getValue(PropertyStr.STUBPROPER).split(",");
        StubProper_properIds_List = Arrays.asList(stubProperArr);

        String[] neededPIArr = PropertyUtil.getValue(PropertyStr.NeededPI).split(",");
        needed_pi_properIds_List = Arrays.asList(neededPIArr);

        String[] categoryArr = PropertyUtil.getValue(PropertyStr.CATEGORY).split(",");
        category_list = Arrays.asList(categoryArr);

        jsonMappingMap = getJsonMapping(jsonMapping);
    }
}
